<script>
export default {
	name: 'DatePicker',
	props: {
		start: {
			type: String,
			default: '',
		},
		end: {
			type: String,
			default: '',
		},
	},
	computed: {
		date: {
			get() {
				return [this.start, this.end];
			},
			set(e) {
				if (e) {
					//结束日期修改为23:59:59
					let res = this.$dayjs(e[1]).unix() * 1000 + (24 * 60 * 60 * 1000 - 1);
					let startDate = this.$dayjs(e[0]).format('YYYY-MM-DDTHH:mm:ss');
					let endDate = this.$dayjs(res).format('YYYY-MM-DDTHH:mm:ss');
					this.$emit('update:start', startDate);
					this.$emit('update:end', endDate);
				} else {
					this.$emit('update:start', '');
					this.$emit('update:end', '');
				}
			},
		},
	},
};
</script>
<template>
	<el-date-picker
		v-model="date"
		type="daterange"
		value-format="YYYY-MM-DD HH:mm:ss"
		range-separator="-"
		start-placeholder="开始日期"
		end-placeholder="结束日期"
	>
	</el-date-picker>
</template>

<style lang="scss">
.el-date-editor {
	.el-range-separator {
		padding: 0;
	}
}
</style>
